package com.gastudio.SMSimple;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;

import java.nio.charset.Charset;

/**
 * Created by 余艾龙 on 2017/6/21.
 */
public class ProtocolFactory implements ProtocolCodecFactory {
    private final NormalDecoder decoder;
    private final NormalEncoder encoder;
    public ProtocolFactory(Charset charset){
        encoder=new NormalEncoder(charset);
        decoder=new NormalDecoder(charset);
    }
    @Override
    public NormalEncoder getEncoder(IoSession ioSession) throws Exception {
        return encoder;
    }

    @Override
    public NormalDecoder getDecoder(IoSession ioSession) throws Exception {
        return decoder;
    }
}
